<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>探究种子萌发的外部条件</title>
    <style>
        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
            font-family: 'Microsoft YaHei', sans-serif;
        }

        body {
            background-color: #f0f7ff;
            color: #333;
            padding: 20px;
            max-width: 1400px;
            margin: 0 auto;
        }

        header {
            text-align: center;
            margin-bottom: 30px;
            padding: 20px;
            background: linear-gradient(135deg, #6a89cc, #4a69bd);
            color: white;
            border-radius: 10px;
            box-shadow: 0 4px 6px rgba(0,0,0,0.1);
        }

        h1 {
            font-size: 28px;
            margin-bottom: 10px;
        }

        .instructions {
            font-size: 16px;
            max-width: 800px;
            margin: 0 auto;
            line-height: 1.5;
        }

        .drag-hint {
            font-size: 14px;
            color: #ff9800;
            margin-top: 10px;
            font-weight: bold;
        }

        .container {
            display: flex;
            gap: 20px;
            margin-bottom: 30px;
        }

        @media (max-width: 768px) {
            .container {
                flex-direction: column;
            }
        }

        .materials-panel {
            flex: 1;
            background-color: white;
            border-radius: 10px;
            padding: 20px;
            box-shadow: 0 4px 6px rgba(0,0,0,0.1);
            position: relative;
        }

        .materials-panel h2 {
            color: #4a69bd;
            margin-bottom: 15px;
            padding-bottom: 10px;
            border-bottom: 2px solid #e0e0e0;
        }

        .reset-container {
            margin-top: 20px;
            text-align: center;
        }

        .materials-grid {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 15px;
        }

        .material-item {
            background-color: #e3f2fd;
            border: 2px dashed #90caf9;
            border-radius: 8px;
            padding: 15px;
            text-align: center;
            cursor: grab;
            transition: all 0.3s;
            user-select: none;
        }

        .material-item.dragging {
            opacity: 0.5;
            transform: rotate(5deg);
        }

        .material-item:hover {
            transform: translateY(-5px);
            box-shadow: 0 5px 15px rgba(0,0,0,0.1);
            background-color: #bbdefb;
        }

        .material-item:active {
            cursor: grabbing;
        }

        .material-icon {
            margin-bottom: 8px;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 60px;
        }

        .seeds-icon {
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
            gap: 3px;
            max-width: 60px;
            margin: 0 auto;
        }

        .seed {
            width: 8px;
            height: 8px;
            background-color: #4caf50;
            border-radius: 50%;
        }

        .water-icon {
            width: 40px;
            height: 40px;
            background: linear-gradient(to bottom, #2196f3, #64b5f6);
            border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
            margin: 0 auto;
            position: relative;
        }

        .water-icon:after {
            content: "";
            position: absolute;
            top: 5px;
            left: 5px;
            width: 10px;
            height: 10px;
            background: rgba(255, 255, 255, 0.5);
            border-radius: 50%;
        }

        .temperature-icon {
            display: inline-block;
            width: 40px;
            height: 40px;
            border-radius: 50%;
            text-align: center;
            line-height: 40px;
            font-size: 16px;
            color: white;
            margin: 0 auto;
        }

        .warm {
            background-color: #ff5722;
        }

        .cold {
            background-color: #2196f3;
        }

        .experiment-area {
            flex: 2;
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 20px;
        }

        @media (max-width: 768px) {
            .experiment-area {
                grid-template-columns: 1fr;
            }
        }

        .experiment-group {
            background-color: white;
            border-radius: 10px;
            padding: 20px;
            box-shadow: 0 4px 6px rgba(0,0,0,0.1);
            display: flex;
            flex-direction: column;
            align-items: center;
            transition: all 0.3s;
            border: 2px solid transparent;
        }

        .experiment-group.active {
            border-color: #4a69bd;
            background-color: #f8fbff;
            transform: scale(1.02);
        }

        .group-title {
            font-weight: bold;
            margin-bottom: 15px;
            color: #4a69bd;
            text-align: center;
            font-size: 18px;
        }

        .group-description {
            font-size: 14px;
            color: #666;
            margin-bottom: 15px;
            text-align: center;
            height: 50px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .flask-container {
            width: 160px;
            height: 180px;
            position: relative;
            margin-bottom: 8px;
        }

        .flask {
            width: 100%;
            height: 100%;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .flask img {
            width: 100%;
            height: 100%;
            object-fit: contain;
            pointer-events: none;
            user-select: none;
        }

        .flask-content {
            position: absolute;
            top: -9999px;
            left: -9999px;
            visibility: hidden;
        }

        .experiment-conditions {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
            gap: 8px;
            margin-top: 8px;
            width: 100%;
        }

        .condition-item {
            background-color: #f8f9fa;
            border: 1px solid #dee2e6;
            border-radius: 6px;
            padding: 8px;
            text-align: center;
            font-size: 12px;
            min-height: 50px;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            transition: all 0.2s;
        }

        .condition-item:hover {
            background-color: #e9ecef;
            transform: translateY(-1px);
        }

        .condition-icon {
            margin-bottom: 5px;
        }

        .flask.active {
            border-color: #4a69bd;
            background-color: #f0f7ff;
        }

        .result {
            margin-top: 15px;
            padding: 10px;
            border-radius: 5px;
            text-align: center;
            font-weight: bold;
            min-height: 40px;
            display: flex;
            align-items: center;
            justify-content: center;
            width: 100%;
        }

        .success {
            background-color: #d4edda;
            color: #155724;
            border: 1px solid #c3e6cb;
        }

        .failure {
            background-color: #f8d7da;
            color: #721c24;
            border: 1px solid #f5c6cb;
        }

        .conclusion-area {
            background-color: white;
            border-radius: 10px;
            padding: 25px;
            box-shadow: 0 4px 6px rgba(0,0,0,0.1);
            margin-bottom: 30px;
            display: none;
        }

        .conclusion-area h2 {
            color: #4a69bd;
            margin-bottom: 15px;
        }

        .conclusion-question {
            font-size: 18px;
            margin-bottom: 15px;
            display: flex;
            align-items: center;
            flex-wrap: wrap;
        }

        .conclusion-blank {
            display: inline-block;
            min-width: 700px;
            min-height: 50px;
            border-bottom: 2px dashed #ccc;
            margin: 0 10px;
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            padding: 5px;
            position: relative;
        }

        .conclusion-materials {
            display: flex;
            gap: 15px;
            margin-bottom: 15px;
            flex-wrap: wrap;
        }

        .conclusion-item {
            background-color: #e3f2fd;
            border: 2px dashed #90caf9;
            border-radius: 8px;
            padding: 10px 15px;
            cursor: grab;
            transition: all 0.3s;
            user-select: none;
        }

        .conclusion-item:hover {
            transform: translateY(-3px);
            box-shadow: 0 3px 10px rgba(0,0,0,0.1);
        }

        /* 进度指示器 */
        .progress-indicator {
            background-color: white;
            border-radius: 10px;
            padding: 20px;
            margin-bottom: 20px;
            box-shadow: 0 4px 6px rgba(0,0,0,0.1);
        }

        .progress-steps {
            display: flex;
            justify-content: space-between;
            align-items: center;
            position: relative;
        }

        .progress-step {
            display: flex;
            flex-direction: column;
            align-items: center;
            flex: 1;
            position: relative;
        }

        .step-circle {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background-color: #e0e0e0;
            color: #666;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
            margin-bottom: 8px;
            transition: all 0.3s;
        }

        .step-circle.active {
            background-color: #4a69bd;
            color: white;
        }

        .step-circle.completed {
            background-color: #4caf50;
            color: white;
        }

        .step-label {
            font-size: 12px;
            text-align: center;
            color: #666;
        }

        .step-line {
            position: absolute;
            top: 20px;
            left: 50%;
            width: 100%;
            height: 2px;
            background-color: #e0e0e0;
            z-index: -1;
        }

        .step-line.completed {
            background-color: #4caf50;
        }

        /* 拖拽引导动画 */
        .drag-guide {
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            background: rgba(0,0,0,0.8);
            color: white;
            padding: 20px;
            border-radius: 10px;
            text-align: center;
            z-index: 1000;
            display: none;
        }

        .drag-guide.show {
            display: block;
            animation: fadeIn 0.5s;
        }

        .drag-arrow {
            font-size: 24px;
            animation: bounce 1s infinite;
        }

        @keyframes fadeIn {
            from { opacity: 0; }
            to { opacity: 1; }
        }

        @keyframes bounce {
            0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
            40% { transform: translateY(-10px); }
            60% { transform: translateY(-5px); }
        }

        .experiment-group.guide-highlight {
            animation: pulse 2s infinite;
        }

        @keyframes pulse {
            0% { box-shadow: 0 4px 6px rgba(0,0,0,0.1); }
            50% { box-shadow: 0 4px 20px rgba(74, 105, 189, 0.4); }
            100% { box-shadow: 0 4px 6px rgba(0,0,0,0.1); }
        }

        /* 确认对话框 */
        .confirm-dialog {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0,0,0,0.5);
            display: none;
            justify-content: center;
            align-items: center;
            z-index: 1000;
        }

        .confirm-dialog.show {
            display: flex;
        }

        .dialog-content {
            background: white;
            padding: 30px;
            border-radius: 10px;
            text-align: center;
            max-width: 400px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.3);
        }

        .dialog-buttons {
            margin-top: 20px;
            display: flex;
            gap: 10px;
            justify-content: center;
        }

        .dialog-btn {
            padding: 10px 20px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-weight: bold;
            transition: all 0.3s;
        }

        .dialog-btn.confirm {
            background-color: #f44336;
            color: white;
        }

        .dialog-btn.cancel {
            background-color: #e0e0e0;
            color: #333;
        }

        .dialog-btn:hover {
            transform: translateY(-2px);
        } 10px 15px;
            cursor: grab;
            transition: all 0.3s;
            user-select: none;
        }

        .conclusion-item:hover {
            transform: translateY(-3px);
            box-shadow: 0 3px 10px rgba(0,0,0,0.1);
        }

        .controls {
            display: flex;
            justify-content: center;
            margin-top: 20px;
            margin-bottom: 30px;
        }

        .time-btn {
            padding: 12px 25px;
            border: none;
            border-radius: 5px;
            font-size: 16px;
            cursor: pointer;
            transition: all 0.3s;
            font-weight: bold;
            background-color: #4caf50;
            color: white;
        }

        .time-btn:hover {
            background-color: #388e3c;
        }

        .reset-btn {
            padding: 12px 25px;
            border: none;
            border-radius: 5px;
            font-size: 16px;
            cursor: pointer;
            transition: all 0.3s;
            font-weight: bold;
            background-color: #f44336;
            color: white;
        }

        .reset-btn:hover {
            background-color: #d32f2f;
        }

        .dropped-item {
            background-color: rgba(227, 242, 253, 0.8);
            border: 1px solid #90caf9;
            border-radius: 5px;
            padding: 5px 8px;
            display: flex;
            align-items: center;
            gap: 3px;
            font-size: 12px;
            margin: 2px;
        }

        .dropped-item .material-icon {
            margin-bottom: 0;
            height: 20px;
        }

        .dropped-seeds {
            display: flex;
            flex-wrap: wrap;
            gap: 1px;
            max-width: 30px;
        }

        .dropped-seed {
            width: 4px;
            height: 4px;
            background-color: #4caf50;
            border-radius: 50%;
        }

        .germination-animation {
            width: 100px;
            height: 100px;
            position: relative;
            margin: 0 auto;
        }

        .seed-germ {
            position: absolute;
            bottom: 0;
            left: 50%;
            transform: translateX(-50%);
            width: 20px;
            height: 20px;
            background-color: #8d6e63;
            border-radius: 50%;
            animation: grow 2s forwards;
        }

        .sprout {
            position: absolute;
            bottom: 20px;
            left: 50%;
            transform: translateX(-50%);
            width: 4px;
            height: 0;
            background-color: #4caf50;
            border-radius: 2px;
            animation: sprout 2s 1s forwards;
        }

        .leaf {
            position: absolute;
            bottom: 40px;
            left: 50%;
            width: 0;
            height: 0;
            border-left: 8px solid transparent;
            border-right: 8px solid transparent;
            border-bottom: 12px solid #4caf50;
            transform: translateX(-50%);
            opacity: 0;
            animation: leaf 2s 2s forwards;
        }

        .leaf-right {
            transform: translateX(-50%) rotate(30deg);
            animation: leaf-right 2s 2s forwards;
        }

        @keyframes grow {
            0% { height: 20px; width: 20px; }
            100% { height: 15px; width: 15px; bottom: 5px; }
        }

        @keyframes sprout {
            0% { height: 0; }
            100% { height: 40px; }
        }

        @keyframes leaf {
            0% { opacity: 0; width: 0; }
            100% { opacity: 1; width: 16px; }
        }

        @keyframes leaf-right {
            0% { opacity: 0; width: 0; }
            100% { opacity: 1; width: 16px; }
        }

        footer {
            text-align: center;
            margin-top: 30px;
            color: #666;
            font-size: 14px;
        }

        .water-level {
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            background: linear-gradient(to top, #2196f3, #64b5f6);
            border-radius: 0 0 38% 38%;
            transition: height 0.5s;
        }

        .seeds-in-flask {
            position: absolute;
            bottom: 10px;
            left: 50%;
            transform: translateX(-50%);
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
            gap: 3px;
            max-width: 80px;
            z-index: 2;
        }

        .seed-in-flask {
            width: 6px;
            height: 6px;
            background-color: #4caf50;
            border-radius: 50%;
        }

        .temp-indicator {
            position: absolute;
            top: 10px;
            right: 10px;
            background: rgba(255,255,255,0.8);
            border-radius: 50%;
            padding: 5px;
            font-size: 12px;
            z-index: 3;
        }

        .conclusion-dropped {
            background-color: #e3f2fd;
            border: 1px solid #90caf9;
            border-radius: 5px;
            padding: 8px 12px;
            margin: 2px;
            display: inline-block;
        }

        .water-label {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            color: white;
            font-weight: bold;
            font-size: 12px;
            text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
            z-index: 4;
        }

        .water-bubbles {
            position: absolute;
            bottom: 10px;
            left: 50%;
            transform: translateX(-50%);
            display: flex;
            gap: 5px;
            z-index: 5;
        }

        .bubble {
            width: 8px;
            height: 8px;
            background-color: rgba(255, 255, 255, 0.7);
            border-radius: 50%;
            animation: bubble-float 3s infinite;
        }

        .bubble:nth-child(2) {
            animation-delay: 0.5s;
        }

        .bubble:nth-child(3) {
            animation-delay: 1s;
        }

        @keyframes bubble-float {
            0% {
                transform: translateY(0);
                opacity: 0.7;
            }
            100% {
                transform: translateY(-20px);
                opacity: 0;
            }
        }
    </style>
</head>
<body>
<header>
    <h1>探究种子萌发的外部条件</h1>
    <p class="instructions">欢迎来到生物实验室！请从左侧拖拽材料到锥形瓶中，为每个组设置不同的环境条件，探究种子萌发的外部条件吧！</p>
    <p class="drag-hint">（长按图片可实现拖拽）</p>
</header>

<div class="container">
    <div class="materials-panel">
        <h2>实验材料</h2>
        <div class="materials-grid">
            <div class="material-item" draggable="true" data-type="seed">
                <div class="material-icon">
                    <div class="seeds-icon">
                        <div class="seed"></div>
                        <div class="seed"></div>
                        <div class="seed"></div>
                        <div class="seed"></div>
                        <div class="seed"></div>
                        <div class="seed"></div>
                        <div class="seed"></div>
                        <div class="seed"></div>
                        <div class="seed"></div>
                        <div class="seed"></div>
                    </div>
                </div>
                <div>种子</div>
            </div>
            <div class="material-item" draggable="true" data-type="water">
                <div class="material-icon">
                    <div class="water-icon"></div>
                </div>
                <div>清水</div>
            </div>
            <div class="material-item" draggable="true" data-type="temp-warm">
                <div class="material-icon">
                    <div class="temperature-icon warm">温</div>
                </div>
                <div>适温</div>
            </div>
            <div class="material-item" draggable="true" data-type="temp-cold">
                <div class="material-icon">
                    <div class="temperature-icon cold">冷</div>
                </div>
                <div>低温</div>
            </div>
        </div>
        <div class="reset-container">
            <button class="reset-btn">重新开始</button>
        </div>
    </div>

    <div class="experiment-area">
        <div class="experiment-group">
            <div class="group-title">对照组</div>
            <div class="group-description">适宜条件</div>
            <div class="flask-container">
                <div class="flask" data-group="control">
                    <img id="control-flask-img" src="images/flask_empty.svg" alt="量杯" draggable="false">
                    <div class="flask-content" id="control-content"></div>
                </div>
            </div>
            <div class="experiment-conditions" id="control-conditions"></div>
            <div class="result" id="control-result"></div>
        </div>

        <div class="experiment-group">
            <div class="group-title">实验组1</div>
            <div class="group-description">探究缺水对种子萌发的影响</div>
            <div class="flask-container">
                <div class="flask" data-group="exp1">
                    <img id="exp1-flask-img" src="images/flask_empty.svg" alt="量杯" draggable="false">
                    <div class="flask-content" id="exp1-content"></div>
                </div>
            </div>
            <div class="experiment-conditions" id="exp1-conditions"></div>
            <div class="result" id="exp1-result"></div>
        </div>

        <div class="experiment-group">
            <div class="group-title">实验组2</div>
            <div class="group-description">探究缺乏空气对种子萌发的影响<br>（拖拽2次或以上清水淹没种子）</div>
            <div class="flask-container">
                <div class="flask" data-group="exp2">
                    <img id="exp2-flask-img" src="images/flask_empty.svg" alt="量杯" draggable="false">
                    <div class="flask-content" id="exp2-content"></div>
                </div>
            </div>
            <div class="experiment-conditions" id="exp2-conditions"></div>
            <div class="result" id="exp2-result"></div>
        </div>

        <div class="experiment-group">
            <div class="group-title">实验组3</div>
            <div class="group-description">探究低温对种子萌发的影响</div>
            <div class="flask-container">
                <div class="flask" data-group="exp3">
                    <img id="exp3-flask-img" src="images/flask_empty.svg" alt="量杯" draggable="false">
                    <div class="flask-content" id="exp3-content"></div>
                </div>
            </div>
            <div class="experiment-conditions" id="exp3-conditions"></div>
            <div class="result" id="exp3-result"></div>
        </div>
    </div>
</div>

<div class="controls">
    <button class="time-btn">一段时间后，观察种子萌发情况</button>
</div>

<div class="conclusion-area">
    <h2>实验结论</h2>
    <div class="conclusion-question">
        我的结论是：种子萌发需要的外界条件是
        <div class="conclusion-blank" id="conclusion-drop"></div>
    </div>

    <div class="conclusion-materials">
        <div class="conclusion-item" draggable="true" data-type="water-conclusion">
            种子萌发需要适量的水
        </div>
        <div class="conclusion-item" draggable="true" data-type="temp-conclusion">
            种子萌发需要适宜的温度
        </div>
        <div class="conclusion-item" draggable="true" data-type="air-conclusion">
            种子萌发需要充足的空气
        </div>
    </div>
</div>

<footer>
    <p>初中生物教学工具 - 种子萌发条件探究实验</p>
</footer>

<script>
    document.addEventListener('DOMContentLoaded', function() {
        // 获取所有可拖拽元素
        const draggables = document.querySelectorAll('.material-item');
        // 获取所有锥形瓶
        const flasks = document.querySelectorAll('.flask');
        // 获取结论区域
        const conclusionDrop = document.getElementById('conclusion-drop');
        // 获取结论材料
        const conclusionItems = document.querySelectorAll('.conclusion-item');

        // 为每个可拖拽元素添加事件监听
        draggables.forEach(item => {
            item.addEventListener('dragstart', dragStart);
        });

        // 为每个实验组添加事件监听（整个方框都可以拖拽）
        const experimentGroups = document.querySelectorAll('.experiment-group');
        experimentGroups.forEach(group => {
            group.addEventListener('dragover', dragOver);
            group.addEventListener('dragenter', dragEnter);
            group.addEventListener('dragleave', dragLeave);
            group.addEventListener('drop', dropToGroup);
        });

        // 为结论材料添加事件监听（结论材料不需要拖拽动画）
        conclusionItems.forEach(item => {
            item.addEventListener('dragstart', function(e) {
                e.dataTransfer.setData('text/plain', e.target.dataset.type);
            });
        });

        // 为材料项添加dragend事件
        draggables.forEach(item => {
            item.addEventListener('dragend', function() {
                this.classList.remove('dragging');
            });
        });

        // 为结论区域添加事件监听
        conclusionDrop.addEventListener('dragover', dragOver);
        conclusionDrop.addEventListener('dragenter', dragEnter);
        conclusionDrop.addEventListener('dragleave', dragLeave);
        conclusionDrop.addEventListener('drop', dropConclusion);

        // 时间按钮事件
        document.querySelector('.time-btn').addEventListener('click', verifyExperiment);

        // 重置按钮事件
        document.querySelector('.reset-btn').addEventListener('click', showResetConfirm);

        // 进度步骤
        let currentStep = 1;
        const totalSteps = 3;

        // 初始化进度指示器
        initProgressIndicator();

        // 显示拖拽引导
        setTimeout(showDragGuide, 2000);

        // 拖拽开始
        function dragStart(e) {
            e.dataTransfer.setData('text/plain', e.target.dataset.type);
            // 只有左侧材料面板的元素才添加拖拽动画
            if (e.target.closest('.materials-panel')) {
                e.target.classList.add('dragging');
            }
        }

        // 拖拽经过投放区域
        function dragOver(e) {
            e.preventDefault();
        }

        // 拖拽进入投放区域
        function dragEnter(e) {
            e.preventDefault();
            this.classList.add('active');
        }

        // 拖拽离开投放区域
        function dragLeave(e) {
            // 只有当真正离开元素时才移除active类
            if (!this.contains(e.relatedTarget)) {
                this.classList.remove('active');
            }
        }

        // 投放实验材料到实验组
        function dropToGroup(e) {
            e.preventDefault();
            this.classList.remove('active');

            const data = e.dataTransfer.getData('text/plain');
            const flask = this.querySelector('.flask');
            const group = flask.dataset.group;
            const flaskContent = document.getElementById(`${group}-content`);
            
            // 隐藏拖拽引导
            hideDragGuide();
            
            // 检查是否已存在相同类型的条件（水除外）
            const existingItems = flaskContent.querySelectorAll('.dropped-item');
            const existingTypes = Array.from(existingItems).map(item => item.dataset.type);
            
            if (data !== 'water' && existingTypes.includes(data)) {
                // 如果不是水且已存在相同类型，不允许添加
                draggables.forEach(item => {
                    item.classList.remove('dragging');
                });
                return;
            }
            
            // 对于水，最多允许2次
            if (data === 'water') {
                const waterCount = existingTypes.filter(type => type === 'water').length;
                if (waterCount >= 2) {
                    draggables.forEach(item => {
                        item.classList.remove('dragging');
                    });
                    return;
                }
            }

            // 创建投放的元素
            const droppedItem = document.createElement('div');
            droppedItem.className = 'dropped-item';
            droppedItem.dataset.type = data;

            // 根据数据类型设置内容
            switch(data) {
                case 'seed':
                    droppedItem.innerHTML = `
                            <div class="material-icon">
                                <div class="dropped-seeds">
                                    <div class="dropped-seed"></div>
                                    <div class="dropped-seed"></div>
                                    <div class="dropped-seed"></div>
                                    <div class="dropped-seed"></div>
                                    <div class="dropped-seed"></div>
                                    <div class="dropped-seed"></div>
                                    <div class="dropped-seed"></div>
                                    <div class="dropped-seed"></div>
                                    <div class="dropped-seed"></div>
                                    <div class="dropped-seed"></div>
                                </div>
                            </div>
                            <span>种子</span>`;
                    // 在锥形瓶中显示种子
                    updateFlaskSeeds(group, true);
                    break;
                case 'water':
                    droppedItem.innerHTML = '<div class="material-icon"><div class="water-icon"></div></div><span>清水</span>';
                    // 在锥形瓶中更新水位
                    updateWaterLevel(group);
                    break;
                case 'temp-warm':
                    droppedItem.innerHTML = '<div class="material-icon"><div class="temperature-icon warm">温</div></div><span>适温</span>';
                    break;
                case 'temp-cold':
                    droppedItem.innerHTML = '<div class="material-icon"><div class="temperature-icon cold">冷</div></div><span>低温</span>';
                    break;
            }

            // 添加删除按钮
            const removeBtn = document.createElement('span');
            removeBtn.innerHTML = '❌';
            removeBtn.style.cursor = 'pointer';
            removeBtn.style.marginLeft = '5px';
            removeBtn.addEventListener('click', function() {
                // 移除材料
                droppedItem.remove();
                
                // 更新显示
                updateFlaskImage(group);
                updateConditions(group);
                if (data === 'temp-warm' || data === 'temp-cold') {
                    removeTemperatureIndicator(group);
                }
            });

            droppedItem.appendChild(removeBtn);
            flaskContent.appendChild(droppedItem);

            // 统一更新显示
            updateFlaskImage(group);
            updateConditions(group);
            if (data === 'temp-warm') {
                updateTemperatureIndicator(group, 'warm');
            } else if (data === 'temp-cold') {
                updateTemperatureIndicator(group, 'cold');
            }

            // 恢复原始元素的样式
            draggables.forEach(item => {
                item.classList.remove('dragging');
            });
            conclusionItems.forEach(item => {
                item.classList.remove('dragging');
            });
        }

        // 更新量杯图片显示
        function updateFlaskImage(group) {
            const flaskImg = document.getElementById(`${group}-flask-img`);
            const flaskContent = document.getElementById(`${group}-content`);
            const items = flaskContent.querySelectorAll('.dropped-item');
            
            const hasSeed = Array.from(items).some(item => item.dataset.type === 'seed');
            const waterItems = Array.from(items).filter(item => item.dataset.type === 'water');
            const waterCount = waterItems.length;
            
            // 根据条件选择合适的图片
            if (!hasSeed && waterCount === 0) {
                flaskImg.src = 'images/flask_empty.svg';
            } else if (hasSeed && waterCount === 0) {
                flaskImg.src = 'images/flask_seeds_only.svg'; // 只有种子，显示种子在瓶底
            } else if (!hasSeed && waterCount === 1) {
                flaskImg.src = 'images/flask_water_little.svg';
            } else if (!hasSeed && waterCount >= 2) {
                flaskImg.src = 'images/flask_water_full.svg';
            } else if (hasSeed && waterCount === 1) {
                flaskImg.src = 'images/flask_water_seeds.svg';
            } else if (hasSeed && waterCount >= 2) {
                flaskImg.src = 'images/flask_water_full_seeds.svg'; // 种子被水淹没
            }
        }

        // 更新条件显示
        function updateConditions(group) {
            const flaskContent = document.getElementById(`${group}-content`);
            const conditionsContainer = document.getElementById(`${group}-conditions`);
            
            // 清空条件显示区域
            conditionsContainer.innerHTML = '';
            
            // 获取所有投放的材料
            const items = flaskContent.querySelectorAll('.dropped-item');
            
            // 为每个材料创建条件显示（只显示文字）
            items.forEach((item, index) => {
                const conditionItem = document.createElement('div');
                conditionItem.className = 'condition-item';
                conditionItem.style.position = 'relative';
                
                // 根据材料类型显示对应文字
                const dataType = item.dataset.type;
                let text = '';
                switch(dataType) {
                    case 'seed':
                        text = '种子';
                        break;
                    case 'water':
                        text = '清水';
                        break;
                    case 'temp-warm':
                        text = '适温';
                        break;
                    case 'temp-cold':
                        text = '低温';
                        break;
                }
                
                conditionItem.textContent = text;
                
                // 添加删除按钮
                const deleteBtn = document.createElement('span');
                deleteBtn.innerHTML = '❌';
                deleteBtn.style.position = 'absolute';
                deleteBtn.style.top = '2px';
                deleteBtn.style.right = '2px';
                deleteBtn.style.cursor = 'pointer';
                deleteBtn.style.fontSize = '10px';
                deleteBtn.style.opacity = '0.7';
                deleteBtn.addEventListener('click', function() {
                    // 找到对应的原始材料并删除
                    const originalItem = Array.from(flaskContent.children)[index];
                    if (originalItem) {
                        originalItem.remove();
                        // 更新显示
                        updateFlaskImage(group);
                        updateConditions(group);
                        if (dataType === 'temp-warm' || dataType === 'temp-cold') {
                            removeTemperatureIndicator(group);
                        }
                    }
                });
                
                conditionItem.appendChild(deleteBtn);
                conditionsContainer.appendChild(conditionItem);
            });
        }

        // 更新锥形瓶中的种子显示
        function updateFlaskSeeds(group, add) {
            updateFlaskImage(group);
            updateConditions(group);
        }

        // 更新锥形瓶中的水位
        function updateWaterLevel(group, remove) {
            updateFlaskImage(group);
            updateConditions(group);
        }

        // 更新温度指示器
        function updateTemperatureIndicator(group, type) {
            const flask = document.querySelector(`.flask[data-group="${group}"]`);
            let indicator = flask.querySelector('.temp-indicator');

            if (!indicator) {
                indicator = document.createElement('div');
                indicator.className = 'temp-indicator';
                indicator.style.position = 'absolute';
                indicator.style.top = '10px';
                indicator.style.right = '10px';
                indicator.style.zIndex = '15';
                flask.appendChild(indicator);
            }

            if (type === 'warm') {
                indicator.innerHTML = '<div class="temperature-icon warm" style="width:30px;height:30px;line-height:30px;font-size:14px;">温</div>';
            } else {
                indicator.innerHTML = '<div class="temperature-icon cold" style="width:30px;height:30px;line-height:30px;font-size:14px;">冷</div>';
            }
        }

        // 移除温度指示器
        function removeTemperatureIndicator(group) {
            const flask = document.querySelector(`.flask[data-group="${group}"]`);
            const indicator = flask.querySelector('.temp-indicator');
            if (indicator) {
                indicator.remove();
            }
        }

        // 投放结论
        function dropConclusion(e) {
            e.preventDefault();
            this.classList.remove('active');

            const data = e.dataTransfer.getData('text/plain');

            // 检查是否已存在相同类型的结论
            const existingItems = this.querySelectorAll(`.conclusion-dropped[data-type="${data}"]`);
            if (existingItems.length > 0) {
                // 如果已经存在，不重复添加
                return;
            }

            // 创建投放的结论元素
            const droppedConclusion = document.createElement('div');
            droppedConclusion.className = 'conclusion-dropped';
            droppedConclusion.dataset.type = data;

            // 根据数据类型设置内容
            switch(data) {
                case 'water-conclusion':
                    droppedConclusion.textContent = '种子萌发需要适量的水';
                    break;
                case 'temp-conclusion':
                    droppedConclusion.textContent = '种子萌发需要适宜的温度';
                    break;
                case 'air-conclusion':
                    droppedConclusion.textContent = '种子萌发需要充足的空气';
                    break;
            }

            this.appendChild(droppedConclusion);

            // 检查是否完成所有结论
            const totalConclusions = this.querySelectorAll('.conclusion-dropped').length;
            if (totalConclusions >= 2) {
                // 更新进度到第3步
                updateProgress(3);
            }

            // 恢复原始元素的样式
            conclusionItems.forEach(item => {
                item.classList.remove('dragging');
            });
        }

        // 验证实验设计
        function verifyExperiment() {
            // 隐藏拖拽引导
            hideDragGuide();
            
            // 更新进度到第2步
            updateProgress(2);
            
            // 显示结论区域
            document.querySelector('.conclusion-area').style.display = 'block';
            
            // 清空之前的结果
            document.querySelectorAll('.result').forEach(result => {
                result.textContent = '';
                result.className = 'result';
            });

            // 验证每个实验组
            flasks.forEach(flask => {
                const group = flask.dataset.group;
                const flaskContent = document.getElementById(`${group}-content`);
                const items = flaskContent.querySelectorAll('.dropped-item');
                const resultElement = document.getElementById(`${group}-result`);

                // 检查是否包含种子
                const hasSeed = Array.from(items).some(item => item.dataset.type === 'seed');

                if (!hasSeed) {
                    resultElement.textContent = '实验设计不完整，缺少种子';
                    resultElement.className = 'result failure';
                    return;
                }

                // 根据实验组类型验证条件
                let isValid = false;
                let message = '';

                switch(group) {
                    case 'control':
                        // 对照组：需要水、适宜温度
                        const hasWater = Array.from(items).some(item => item.dataset.type === 'water');
                        const hasWarmTemp = Array.from(items).some(item => item.dataset.type === 'temp-warm');

                        isValid = hasWater && hasWarmTemp;
                        if (isValid) {
                            resultElement.innerHTML = '<div class="germination-animation"><div class="seed-germ"></div><div class="sprout"></div><div class="leaf"></div><div class="leaf leaf-right"></div></div><div>种子萌发成功！</div>';
                            resultElement.className = 'result success';
                        } else {
                            resultElement.textContent = '种子未萌发';
                            resultElement.className = 'result failure';
                        }
                        break;

                    case 'exp1':
                        // 实验组1（缺水组）：不能有水，但要有适宜温度
                        const hasWaterExp1 = Array.from(items).some(item => item.dataset.type === 'water');
                        const hasWarmTempExp1 = Array.from(items).some(item => item.dataset.type === 'temp-warm');

                        isValid = !hasWaterExp1 && hasWarmTempExp1;
                        message = isValid ? '种子未萌发（缺水）' : '实验条件不正确';
                        resultElement.textContent = message;
                        resultElement.className = `result ${isValid ? 'success' : 'failure'}`;
                        break;

                    case 'exp2':
                        // 实验组2（缺空气组）：需要水完全覆盖种子（这里简化为有两次水），适宜温度
                        const waterItemsExp2 = Array.from(items).filter(item => item.dataset.type === 'water');
                        const hasWarmTempExp2 = Array.from(items).some(item => item.dataset.type === 'temp-warm');

                        isValid = waterItemsExp2.length >= 2 && hasWarmTempExp2;
                        message = isValid ? '种子未萌发（缺空气）' : '实验条件不正确';
                        resultElement.textContent = message;
                        resultElement.className = `result ${isValid ? 'success' : 'failure'}`;
                        break;

                    case 'exp3':
                        // 实验组3（低温组）：需要水，低温
                        const hasWaterExp3 = Array.from(items).some(item => item.dataset.type === 'water');
                        const hasColdTemp = Array.from(items).some(item => item.dataset.type === 'temp-cold');

                        isValid = hasWaterExp3 && hasColdTemp;
                        message = isValid ? '种子未萌发（温度过低）' : '实验条件不正确';
                        resultElement.textContent = message;
                        resultElement.className = `result ${isValid ? 'success' : 'failure'}`;
                        break;
                }
            });
        }

        // 初始化进度指示器
        function initProgressIndicator() {
            const progressHtml = `
                <div class="progress-indicator">
                    <div class="progress-steps">
                        <div class="progress-step">
                            <div class="step-circle active" id="step-1">1</div>
                            <div class="step-label">设置实验条件</div>
                            <div class="step-line" id="line-1"></div>
                        </div>
                        <div class="progress-step">
                            <div class="step-circle" id="step-2">2</div>
                            <div class="step-label">观察实验结果</div>
                            <div class="step-line" id="line-2"></div>
                        </div>
                        <div class="progress-step">
                            <div class="step-circle" id="step-3">3</div>
                            <div class="step-label">得出实验结论</div>
                        </div>
                    </div>
                </div>
            `;
            document.querySelector('.container').insertAdjacentHTML('beforebegin', progressHtml);
        }

        // 更新进度
        function updateProgress(step) {
            currentStep = step;
            
            // 更新步骤圆圈
            for (let i = 1; i <= totalSteps; i++) {
                const circle = document.getElementById(`step-${i}`);
                const line = document.getElementById(`line-${i}`);
                
                if (i < step) {
                    circle.className = 'step-circle completed';
                    if (line) line.className = 'step-line completed';
                } else if (i === step) {
                    circle.className = 'step-circle active';
                } else {
                    circle.className = 'step-circle';
                    if (line) line.className = 'step-line';
                }
            }
        }

        // 显示拖拽引导
        function showDragGuide() {
            if (currentStep === 1) {
                const guideHtml = `
                    <div class="drag-guide" id="drag-guide">
                        <div class="drag-arrow">👆</div>
                        <p>拖拽左侧材料到实验组中</p>
                        <p>为每个实验组设置不同条件</p>
                        <button onclick="hideDragGuide()" style="margin-top:10px;padding:5px 15px;border:none;border-radius:5px;background:#4a69bd;color:white;cursor:pointer;">知道了</button>
                    </div>
                `;
                document.body.insertAdjacentHTML('beforeend', guideHtml);
                document.getElementById('drag-guide').classList.add('show');
                
                // 高亮实验组
                document.querySelectorAll('.experiment-group').forEach(group => {
                    group.classList.add('guide-highlight');
                });
            }
        }

        // 隐藏拖拽引导
        function hideDragGuide() {
            const guide = document.getElementById('drag-guide');
            if (guide) {
                guide.remove();
            }
            document.querySelectorAll('.experiment-group').forEach(group => {
                group.classList.remove('guide-highlight');
            });
        }

        // 显示重置确认对话框
        function showResetConfirm() {
            const dialogHtml = `
                <div class="confirm-dialog" id="reset-dialog">
                    <div class="dialog-content">
                        <h3>确认重置</h3>
                        <p>确定要重新开始实验吗？这将清除所有已设置的条件和结果。</p>
                        <div class="dialog-buttons">
                            <button class="dialog-btn cancel" onclick="hideResetDialog()">取消</button>
                            <button class="dialog-btn confirm" onclick="confirmReset()">确定重置</button>
                        </div>
                    </div>
                </div>
            `;
            document.body.insertAdjacentHTML('beforeend', dialogHtml);
            document.getElementById('reset-dialog').classList.add('show');
        }

        // 隐藏重置对话框
        function hideResetDialog() {
            const dialog = document.getElementById('reset-dialog');
            if (dialog) {
                dialog.remove();
            }
        }

        // 确认重置
        function confirmReset() {
            hideResetDialog();
            resetExperiment();
        }

        // 重置实验
        function resetExperiment() {
            // 清空所有锥形瓶内容
            document.querySelectorAll('.flask-content').forEach(content => {
                content.innerHTML = '';
            });

            // 清空所有结果
            document.querySelectorAll('.result').forEach(result => {
                result.textContent = '';
                result.className = 'result';
            });

            // 清空结论区域
            conclusionDrop.innerHTML = '';
            document.querySelector('.conclusion-area').style.display = 'none';

            // 重置所有量杯图片
            document.querySelectorAll('[id$="-flask-img"]').forEach(img => {
                img.src = 'images/flask_empty.svg';
            });
            document.querySelectorAll('.temp-indicator').forEach(indicator => {
                indicator.remove();
            });
            
            // 重置条件显示
            ['control', 'exp1', 'exp2', 'exp3'].forEach(group => {
                updateConditions(group);
            });

            // 重置进度
            updateProgress(1);
        }

        // 将函数添加到全局作用域
        window.hideDragGuide = hideDragGuide;
        window.hideResetDialog = hideResetDialog;
        window.confirmReset = confirmReset;
    });
</script>
</body>
</html>